import json

import requests  # 配置北向用户信息及北向地址nbi_name = "campus02@north.com"
from urllib3.exceptions import InsecureRequestWarning

from DjangoDemo.scripts.Http_Management import Http_Management
from DjangoDemo.scripts.SiteID import Sites
from DjangoDemo.scripts.Token import Token


class c2_4:
    # 默认深圳
    def __init__(self, site_name):

        self.site_name = Sites.get_mac(site_name)
        self.token = Token()
        # 定义接口的 URI
        GET_JOURNEY_URI = "/rest/campusclientservice/v1/clientoverview/userstatistics/trend"
        # 配置 URL 和 Headers
        param = '''{
                "regionType":"site",
                "level":"1",
                "tenantId":"default-organization-id",
                "startTime":"1623906000000",
                "endTime":"1624078800000",
                "id":"%s",
                "showType":"radio",
                "isAutoRefresh":"false"}''' % self.site_name

        self.r = Http_Management(self.token).get(GET_JOURNEY_URI, param)

if __name__ == '__main__':
    now = c2_4("Shenzhen")
    print(now.r.json())

# {
# 	"userType":"journey",	有线、无线旅程
# 	# "key":"",组织id
# 	"tenantId":"defaultorganizationid",日期信息
# 	"startTime":"1623906000000",开始时间
# 	"endTime":"1624078800000",结束时间
# 	"userMac":"30-00-00-00-00-30",用户mac
# 	"trendType":"2"聚合类型
# }


'''
{
    "regionType":"site",
    "level":"0",
    "tenantId":"default-organization-id",
    "startTime":"1623906000000",
    "endTime":"1624078800000",
    "id":"857b706e-67d9-49c0-b3cd-4bd1e6963c07",
    "showType":"radio",
    "isAutoRefresh":"false"
}
'''
